package ysq.xyg.recovery.controller;

import cn.hutool.core.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import ysq.xyg.base.aspect.BaseLog;
import ysq.xyg.base.controller.BaseController;
import ysq.xyg.base.model.dto.ReturnEntity;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.recovery.model.po.RecoverySackDetail;
import ysq.xyg.recovery.model.vo.RecoverySackDetailVo;
import ysq.xyg.recovery.service.RecoverySackDetailService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 回收金模块-袋子详情表controller层
 *
 * @author congcong tao
 * @date 2019-7-3 20:51:03
 */
@RestController
public class RecoverySackDetailController extends BaseController {

    private static Logger log= LoggerFactory.getLogger(RecoverySackDetailController.class);
    @Resource
    private RecoverySackDetailService recoverySackDetailService;

    private RecoverySackDetail recoverySackDetail;

    /**
     * 分页查询
     *
     * @param recoverySackDetailVo 对象
     * @param pageSize 展示数量
     * @param pageNum 当前页面
     * @author congcong tao
     * @date 2019-7-3 20:51:03
     */
    @BaseLog(module = "回收金模块",className = "袋子详情表",methods = "分页查询",businessType = BaseConstant.SYS_BUSINESS_TYPE_GET,operatorType= BaseConstant.SYS_OPERATOR_TYPE_PC)
    @RequestMapping(value = "/recoverySackDetail/page",method = RequestMethod.POST)
    public ReturnEntity page(RecoverySackDetailVo recoverySackDetailVo, int pageSize, int pageNum){
        ReturnEntity returnEntity = recoverySackDetailService.page(recoverySackDetailVo,pageSize,pageNum);
        return returnEntity;
    }

    /**
     * 跳转连接
     *
     * @param id 主键id
     * @author congcong tao
     * @date 2019-7-3 20:51:03
     */
    @RequestMapping(value = "/recoverySackDetail/getEntity",method = RequestMethod.GET)
    public ModelAndView getEntity(String id, String recordId){
        ModelAndView view = new ModelAndView("recovery/recoverySackDetailUpdateOrSave");
        if(StrUtil.isNotEmpty(id)){
            recoverySackDetail = recoverySackDetailService.selectByPrimaryKey(id);
            view.addObject("recoverySackDetail", recoverySackDetail);
        }
        view.addObject("recordId", recordId);
        return view;
    }

    @RequestMapping(value = "/recoverySackDetail/recoverySackRecordDetailList",method = RequestMethod.GET)
    public ModelAndView recoverySackRecordDetailList(String recordId, String status){
        ModelAndView view = new ModelAndView("recovery/recoverySackDetailList");
        view.addObject("recordId", recordId);
        view.addObject("status", status);
        return view;
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @author congcong tao
     * @date 2019-7-3 20:51:03
     */
    @BaseLog(module = "回收金模块",className = "袋子详情表",methods = "删除",businessType = BaseConstant.SYS_BUSINESS_TYPE_DELETE,operatorType= BaseConstant.SYS_OPERATOR_TYPE_PC)
    @RequestMapping(value = "/recoverySackDetail/delete")
    public ReturnEntity delete(HttpServletRequest request,String id){
        return recoverySackDetailService.delete(id,acceptCurrentUser(request));
    }

    /**
     * 添加或修改
     *
     * @param recoverySackDetailVo Vo对象
     * @author congcong tao
     * @date 2019-7-3 20:51:03
     */
    @BaseLog(module = "回收金模块",className = "袋子详情表",methods = "添加或修改",businessType = BaseConstant.SYS_BUSINESS_TYPE_UPDATE,operatorType= BaseConstant.SYS_OPERATOR_TYPE_PC)
    @RequestMapping(value = "/recoverySackDetail/addOrUpdate",method = RequestMethod.POST)
    public ReturnEntity addOrUpdate(HttpServletRequest request,RecoverySackDetailVo recoverySackDetailVo){
        return recoverySackDetailService.addOrUpdate(recoverySackDetailVo,acceptCurrentUser(request));
    }
}